import 'package:basic_common/common_exports.dart';

import '../mypresclist/model/presc_detail_data.dart';

class MyPrescDetailController extends GetxController {
  final prescDetailData = PrescDetailData().obs;
  final drugsList = <Drugs>[].obs;

  /// 获取处方详情
  void getPrescDetail(String precId) async {
    HttpData res =
        await ApiService().getPrescDetail(data: {"prescriptionId": precId});
    if (res.code == 1) {
      prescDetailData.value = PrescDetailData.fromJson(res.data);
      drugsList.value = prescDetailData.value.drugs!;

      update(['drugDetailInfo']);
    }
    update(['drugDetailInfo']);
  }

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    String precid = Get.arguments['prescId'];
    getPrescDetail(precid);
  }
}
